package com.leung.machine.action;


import com.leung.machine.entity.OrderItem;
import com.leung.machine.mapper.OrderItemMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author 丨一
 * @version 1.0
 * @title NewStateAction
 * @description:
 * @date 2025/10/7 上午9:36
 */

@Slf4j
@Component
public class NewStateAction implements StateAction {


    @Resource
    private OrderItemMapper orderItemMapper;


    @Override

    public void execute(DynamicContext dynamicContext) {
        log.info("处理新建订单逻辑");

        OrderItem orderItem = new OrderItem();

        orderItem.setOrderId(dynamicContext.getOrderId());

        orderItem.setItemName(dynamicContext.getItemName());

        orderItem.setQuantity(dynamicContext.getQuantity());

        orderItem.setPrice(dynamicContext.getPrice());

        //入库操作
        orderItemMapper.insert(orderItem);
    }

}
